
/**
* @module create-cancel-message
* @author: Hjava
* @description: 创建撤回消息模块
* @since: 2018-07-23 12:32:15
*/
Object.defineProperty(exports, "__esModule", { value: true });
var models_1 = __webpack_require__(/*! ../models */ "./src/extra/models/index.ts");
var timer_1 = __webpack_require__(/*! _util/timer */ "./src/core/utils/timer.ts");
function createMessage(messageDatum) {
    var sessionType = messageDatum.sessionType;
    switch (sessionType) {
        case models_1.Session.TYPE.CHAT: {
            return createChatCancelMessage(messageDatum);
        }
        case models_1.Session.TYPE.CHAT2: {
            return createChatCancelMessage2(messageDatum);
        }
        case models_1.Session.TYPE.GROUP_CHAT: {
            return createGroupChatCancelMessage(messageDatum);
        }
        case models_1.Session.TYPE.PUB_CHAT: {
            return createPubChatCancelMessage(messageDatum);
        }
        case models_1.Session.TYPE.PUB_CHAT2: {
            return createPubChatCancelMessage2(messageDatum);
        }
        case models_1.Session.TYPE.CS_CHAT: {
            return createPubKFChatCancelMessage(messageDatum);
        }
        case models_1.Session.TYPE.CS_CHAT2: {
            return createPubKFChatCancelMessage2(messageDatum);
        }
    }
}
exports.default = createMessage;
function createChatCancelMessage(_a) {
    var from = _a.from, to = _a.to, fromName = _a.fromName, mid = _a.mid, toAppId = _a.toAppId, extension = _a.extension, channelId = _a.channelId, uuid = _a.uuid, cts = _a.cts;
    if (true) {
        var IM = __webpack_require__(/*! _core/im */ "./src/core/im/index.ts").default;
        return new IM.Session.IMCancelMsg({
            fromUid: from,
            toUid: to,
            fromName: fromName,
            toAppId: toAppId,
            extension: extension,
            channel: channelId,
            msgId: mid,
            msgUuid: uuid,
            cts: cts && cts > 0 ? cts : timer_1.default.get()
        });
    }
}
function createChatCancelMessage2(_a) {
    var from = _a.from, to = _a.to, fromName = _a.fromName, mid = _a.mid, toAppId = _a.toAppId, extension = _a.extension, channelId = _a.channelId, sid = _a.sid, uuid = _a.uuid, cts = _a.cts;
    if (true) {
        var IM = __webpack_require__(/*! _core/im */ "./src/core/im/index.ts").default;
        return new IM.Session.IMCancelMsg2({
            fromUid: from,
            toUid: to,
            fromName: fromName,
            toAppId: toAppId,
            extension: extension,
            channel: channelId,
            msgId: mid,
            msgUuid: uuid,
            sid: sid,
            cts: cts && cts > 0 ? cts : timer_1.default.get()
        });
    }
}
function createGroupChatCancelMessage(_a) {
    var from = _a.from, to = _a.to, fromName = _a.fromName, groupName = _a.groupName, mid = _a.mid, extension = _a.extension, channelId = _a.channelId, uuid = _a.uuid, adminUid = _a.adminUid, cts = _a.cts;
    /**
        this.uri = constant.IM.URI_IM_CANCEL_GROUP_MSG;
        this.deviceType = deviceInfo.deviceType;
        this.msgUuid = uuid.next();
        this.fromUid = 0;
        this.toGuid = 0;
        this.fromName = ''; //nickname
        this.groupName = ''; //nickname
        this.cts = ctsTimer.get();
        this.msgId = 0;
        this.extension = '';
        this.channel = 0;
        this.isforce = false;
        this.sts = 0;
        this.adminUid = 0;
     */
    if (true) {
        var IM = __webpack_require__(/*! _core/im */ "./src/core/im/index.ts").default;
        return new IM.Session.IMCancelGroupMsg({
            fromUid: from,
            toGuid: to,
            fromName: fromName,
            groupName: groupName,
            extension: extension,
            channel: channelId,
            msgId: mid,
            msgUuid: uuid,
            adminUid: adminUid,
            cts: cts && cts > 0 ? cts : timer_1.default.get()
        });
    }
}
function createPubChatCancelMessage(_a) {
    var from = _a.from, to = _a.to, fromName = _a.fromName, mid = _a.mid, toAppId = _a.toAppId, extension = _a.extension, channelId = _a.channelId, uuid = _a.uuid, cts = _a.cts;
    if (true) {
        var PUB = __webpack_require__(/*! _core/pub */ "./src/core/pub/index.ts").default;
        return new PUB.Session.PubCancelMsg({
            fromUid: from,
            toUid: to,
            toAppId: 0,
            fromName: fromName,
            extension: extension,
            channel: channelId,
            msgId: mid,
            msgUuid: uuid,
            cts: cts && cts > 0 ? cts : timer_1.default.get()
        });
    }
}
function createPubChatCancelMessage2(_a) {
    var from = _a.from, to = _a.to, fromName = _a.fromName, mid = _a.mid, toAppId = _a.toAppId, extension = _a.extension, channelId = _a.channelId, sid = _a.sid, uuid = _a.uuid, cts = _a.cts;
    if (true) {
        var PUB = __webpack_require__(/*! _core/pub */ "./src/core/pub/index.ts").default;
        return new PUB.Session.PubCancelMsg2({
            fromUid: from,
            toUid: to,
            toAppId: 0,
            fromName: fromName,
            extension: extension,
            channel: channelId,
            msgId: mid,
            msgUuid: uuid,
            sid: sid,
            cts: cts && cts > 0 ? cts : timer_1.default.get()
        });
    }
}
function createPubKFChatCancelMessage(_a) {
    var _b;
    var from = _a.from, to = _a.to, belongTo = _a.belongTo, fromName = _a.fromName, mid = _a.mid, toAppId = _a.toAppId, extension = _a.extension, channelId = _a.channelId, uuid = _a.uuid, _c = _a.direction, direction = _c === void 0 ? 1 : _c, cts = _a.cts;
    if (true) {
        var _d = (direction === 1 ? to : from).split('_'), pubId = _d[0], peerUid = _d[1];
        if ((!pubId || !peerUid) && belongTo) {
            _b = (direction === 1 ? belongTo : from).split('_'), pubId = _b[0], peerUid = _b[1];
        }
        var PUB = __webpack_require__(/*! _core/pub */ "./src/core/pub/index.ts").default;
        return new PUB.Session.PubCancelKFMsg({
            fromUid: direction === 1 ? from : peerUid,
            toUid: direction === 1 ? peerUid : to,
            toAppId: 0,
            fromName: fromName,
            extension: extension,
            channel: channelId,
            msgId: mid,
            msgUuid: uuid,
            pubUid: pubId,
            cts: cts && cts > 0 ? cts : timer_1.default.get()
        });
    }
}
function createPubKFChatCancelMessage2(_a) {
    var _b;
    var from = _a.from, to = _a.to, belongTo = _a.belongTo, fromName = _a.fromName, mid = _a.mid, toAppId = _a.toAppId, extension = _a.extension, channelId = _a.channelId, sid = _a.sid, uuid = _a.uuid, _c = _a.direction, direction = _c === void 0 ? 1 : _c, cts = _a.cts;
    if (true) {
        var _d = (direction === 1 ? to : from).split('_'), pubId = _d[0], peerUid = _d[1];
        if ((!pubId || !peerUid) && belongTo) {
            _b = (direction === 1 ? belongTo : from).split('_'), pubId = _b[0], peerUid = _b[1];
        }
        var PUB = __webpack_require__(/*! _core/pub */ "./src/core/pub/index.ts").default;
        return new PUB.Session.PubCancelKFMsg2({
            fromUid: direction === 1 ? from : peerUid,
            toUid: direction === 1 ? peerUid : to,
            toAppId: 0,
            fromName: fromName,
            extension: extension,
            channel: channelId,
            msgId: mid,
            msgUuid: uuid,
            sid: sid,
            pubUid: pubId,
            cts: cts && cts > 0 ? cts : timer_1.default.get()
        });
    }
}


//# sourceURL=webpack://MTDX/./src/extra/utils/create-cancel-message.ts?